<template>
  <el-row :gutter="10" class="mb8">
    <el-col :span="1.5">
      <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
        v-hasPermi="['logistics:shipment:add']">新增</el-button>
    </el-col>
    <el-col :span="1.5">
      <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
        v-hasPermi="['logistics:shipment:edit']">修改</el-button>
    </el-col>
    <el-col :span="1.5">
      <el-tooltip :content="deleteTooltip" placement="top" :disabled="!deleteDisabled">
        <div style="display: inline-block;">
          <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="deleteDisabled"
            @click="handleDelete" v-hasPermi="['logistics:shipment:remove']">删除</el-button>
        </div>
      </el-tooltip>
    </el-col>
    <el-col :span="1.5">
      <el-button type="warning" plain icon="el-icon-download" size="mini" :loading="exportLoading" @click="handleExport"
        v-hasPermi="['logistics:shipment:export']">导出</el-button>
    </el-col>
    <el-col :span="1.5">
      <el-button type="info" plain icon="el-icon-refresh" size="mini" @click="handleRefresh">刷新</el-button>
    </el-col>
    <right-toolbar :showSearch.sync="showSearch" @queryTable="handleRefresh"></right-toolbar>
  </el-row>
</template>

<script>
export default {
  name: 'ShipmentToolbar',
  computed: {
    /** 删除按钮提示信息 */
    deleteTooltip () {
      if (!this.deleteDisabled) {
        return ''
      }
      return '只能删除"待发货"状态的运单'
    }
  },
  props: {
    single: {
      type: Boolean,
      default: true
    },
    multiple: {
      type: Boolean,
      default: true
    },
    deleteDisabled: {
      type: Boolean,
      default: true
    },
    showSearch: {
      type: Boolean,
      default: true
    },
    exportLoading: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    /** 新增按钮操作 */
    handleAdd () {
      this.$emit('add')
    },
    /** 修改按钮操作 */
    handleUpdate () {
      this.$emit('update')
    },
    /** 删除按钮操作 */
    handleDelete () {
      this.$emit('delete')
    },
    /** 导出按钮操作 */
    handleExport () {
      this.$emit('export')
    },
    /** 刷新按钮操作 */
    handleRefresh () {
      this.$emit('refresh')
    }
  }
}
</script>
